import { queryList } from "../../apis/appDefinition"
import { queryList as queryProcessDefinition } from "../../apis/processDefinition"

export const queryAppProcessesAction = (appKey) => {
  return async (dispatch) => {
    const res = await queryProcessDefinition({
      latest: true,
      appDefinitionKey: appKey
    })
    dispatch({
      type: 'SET_PROCESSES',
      data: res.data
    })
  }
}

export const setCurAppAction = (appKey) => {
  return {
    type: 'SET_CUR_APP',
    appKey: appKey
  }
}

export const queryAppDefinitionAction = () => {
  return async (dispatch) => {
    const res = await queryList()
    dispatch({
      type: 'SET_APP_LIST',
      data: res.data
    })
  }
}